PROGRAM MAIN_GLOB

	INTEGER, PARAMETER	:: TABELLA = 14
	INTEGER, PARAMETER	:: PERFPRO = 15
	INTEGER				:: INDFUN, iok, sumiok
	INTEGER				:: I, MYDATE(8)
	INTEGER				:: NF, NFAL, NFTOT, NFALTOT
	INTEGER				:: ICHECK		
!-----------------------------------------------------------------
! INDFUN       : 1  -->  5^n local minima n=2	(LEVY5)
!				 2  -->  5^n local minima n=5	(LEVY5)
!				 3  -->  5^n local minima n=10	(LEVY5)
!				 4  -->  5^n local minima n=20	(LEVY5)
!				 5  --> 10^n local minima n=2	(LEVY10)
!				 6  --> 10^n local minima n=5	(LEVY10)
!				 7  --> 10^n local minima n=10	(LEVY10)
!				 8  --> 10^n local minima n=20	(LEVY10)
!				 9  --> 15^n local minima n=2	(LEVY15)
!				 10 --> 15^n local minima n=5	(LEVY15)
!				 11 --> 15^n local minima n=10	(LEVY15)
!				 12 --> 15^n local minima n=20	(LEVY15)
!				 13 --> six humps camel back	(SIXHUMP)
!				 14 --> cauchy likelyhood m=4   (CAUCHY4)
!				 15 --> cauchy likelyhood m=10  (CAUCHY10)
!				 16 --> cauchy likelyhood m=25  (CAUCHY25)
!				 17 --> cosine mixture n=2		(COSMIX)
!				 18 --> cosine mixture n=4		(COSMIX)
!				 19 --> exponential	   n=2		(EXPONENTIAL)
!				 20 --> exponential	   n=4		(EXPONENTIAL)
!				 21 --> fletcher & powell		(FLETCHERPOWELL)
!				 22 --> goldstein & price		(GOLDSTEINPRICE)
!				 23 --> hartman n=3				(HARTMAN3)
!				 24 --> hartman n=6				(HARTMAN6)
!				 25 --> meyer roth				(MEYERROTH)
!				 26 --> miele & contrell		(MIELECONTRELL)
!				 27 --> poissonian train		(POISSONIAN)
!				 28 --> extended rosenbrock		(EXTROSENBROCK)
!				 29 --> shekel 5  minima		(SHEKEL5)
!				 30 --> shekel 7  minima		(SHEKEL7)
!				 31 --> shekel 10 minima		(SHEKEL10)
!				 32 --> griewank n=2			(GRIEWANK)
!				 33 --> griewank n=5			(GRIEWANK)
!				 34 --> griewank n=10			(GRIEWANK)
!				 35 --> griewank n=20			(GRIEWANK)
!				 36 --> quartic					(QUARTIC)
!				 37 --> schubert				(SCHUBERT)
!				 38 --> schubert pen. 1			(SCHUBERTPEN1)
!				 39 --> schubert pen. 2			(SCHUBERTPEN2)
!				 40 --> treccani				(TRECCANI)
!				 41 --> odessa (INSEAN)			(ODESSA11)
!
!				 200-->  5^n local minima n=30	(LEVY5)
!				 201--> 10^n local minima n=30	(LEVY10)
!				 202--> 15^n local minima n=30	(LEVY15)
!				 203--> griewank n=30			(GRIEWANK)
!
!			   300  --> rastrigin_2	n=2			(RASTRIG2)
!			   301  --> rastrigin_2	n=5			(RASTRIG2)
!			   302  --> rastrigin_2	n=10		(RASTRIG2)
!			   303  --> rastrigin_2	n=20		(RASTRIG2)
!			   304  --> rastrigin_2	n=30		(RASTRIG2)
!			   305  --> rastrigin_2	n=50		(RASTRIG2)
!			   306  --> rastrigin_2	n=100		(RASTRIG2)
!			   307  --> rastrigin_2	n=200		(RASTRIG2)
!			   310  --> schwefel	n=2			(SCHWEFEL)
!			   311  --> schwefel	n=5			(SCHWEFEL)
!			   312  --> schwefel	n=10		(SCHWEFEL)
!			   313  --> schwefel	n=20		(SCHWEFEL)
!			   314  --> schwefel	n=30		(SCHWEFEL)
!			   315  --> schwefel	n=50		(SCHWEFEL)
!			   316  --> schwefel	n=100		(SCHWEFEL)
!			   317  --> schwefel	n=200		(SCHWEFEL)
!			   320  --> modified langerman n=5	(MODLANGERMAN)
!			   330  --> shekel foxholes    n=5  (SHEKELFOX)
!			   340  --> levy 5 n=50	
!			   341  --> levy 5 n=100	
!			   342  --> levy 5 n=200	
!			   350  --> levy 10 n=50	
!			   351  --> levy 10 n=100	
!			   352  --> levy 10 n=200	
!			   360  --> levy 15 n=50	
!			   361  --> levy 15 n=100	
!			   362  --> levy 15 n=200	
!			   370  --> Griewank n=50	
!			   371  --> Griewank 10 n=100	
!			   372  --> Griewank 10 n=200	
!
!-----------------------------------------------------------------

!	open (TABELLA,FILE='risultato.tex',STATUS='OLD',ACCESS='APPEND')

	sumiok = 0

!	do while (sumiok < 21)
1	continue

	OPEN (TABELLA,FILE='risultato.tex',STATUS='REPLACE')
	OPEN (PERFPRO,FILE='perfprofile.txt',STATUS='REPLACE',IOSTAT=ICHECK)
	CALL DATE_AND_TIME(VALUES = MYDATE)
	WRITE(TABELLA,1000) MYDATE(3),MYDATE(2),MYDATE(1)

	sumiok = 0

	!DO I = 1,203 !1,41
	do i = 1,41
		if ((i >= 308).and.(i <= 309)) cycle
		if ((i >= 318).and.(i <= 319)) cycle
		if ((i >= 321).and.(i <= 329)) cycle
		if ((i >= 331).and.(i <= 339)) cycle
		if ((i >= 343).and.(i <= 349)) cycle
		if ((i >= 353).and.(i <= 359)) cycle
		if ((i >= 363).and.(i <= 369)) cycle

!		IF(.not.((I==4).OR.(I==8).OR.(I==12).OR.(I==35).OR. &
!		   (I==200).OR.(I==201).OR.(I==202).OR.(I==203))) cycle

		!IF((I==4).OR.(I==8).OR.(I==12).OR.(I==35)) cycle
		!if(I>41) cycle
		if((I>=14).and.(I<=16)) cycle
		if(I==21) cycle
		if(I==22) cycle
		if((I>=25).and.(I<=28)) cycle

		INDFUN = I
		CALL SENZADERGLOB(INDFUN,TABELLA,PERFPRO,iok)
		sumiok = sumiok + iok
		SELECT CASE(INDFUN)
		CASE(4,8,12,13,16,18,20,21,22,24,25,26,27,28,31,35,36,39,40,41,42,43,44,45,46,49,149,150,151)
			WRITE(TABELLA,*) '\hline'
		END SELECT
	ENDDO

	
	WRITE(TABELLA,1010)
	CLOSE(TABELLA)
!	WRITE(PERFPRO,*)

	REWIND(PERFPRO)

	NFTOT   = 0;
	NFALTOT = 0
	READ(PERFPRO,1020,IOSTAT=ICHECK) NF, NFAL
	DO WHILE (ICHECK == 0)
		NFTOT   = NFTOT   + NF
		NFALTOT = NFALTOT + NFAL
		READ(PERFPRO,1020,IOSTAT=ICHECK) NF, NFAL
	ENDDO

	CLOSE(PERFPRO)
	OPEN (PERFPRO,FILE='perfprofileTOT.txt',STATUS='REPLACE')
	WRITE(PERFPRO,*) NFTOT, NFALTOT
	CLOSE(PERFPRO)

	write(*,*) 'successi = ',sumiok

!	enddo

1020 FORMAT(I6,'  ',I3)
1010 FORMAT('\end{tabular}				',/,&
			'\end{center}				',/,&
			'\end{document}				')

1000 FORMAT('\documentclass[fleqn]{article}				',/,&
			'\pagestyle{plain}							',/,&
			'\usepackage{latexsym}						',/,&
			'\usepackage{amsmath}						',/,/,&
			'\textwidth 20 cm							',/,&
			'\textheight 29 cm							',/,&
			'\oddsidemargin 1.4 cm						',/,&
			'\evensidemargin=\oddsidemargin				',/,&
			'\topmargin -0.3 cm							',/,&
			'%\headheight -1.2 cm						',/,&
			'%\headsep -0.5 cm							',/,&
			'%\topskip -0.3 cm							',/,&
			'\hoffset=-4 cm								',/,&
			'\voffset=-3 cm								',/,&
			'%\mathindent=2 cm							',/,&
			'\parindent 0em								',/,/,&
			'\newcommand{\ba}{\`a}						',/,&
			'\newcommand{\be}{\`e}						',/,&
			'\newcommand{\bE}{\`E}						',/,&
			'\newcommand{\bi}{\`\i}						',/,&
			'\newcommand{\bo}{\`o}						',/,&
			'\newcommand{\bu}{\`u}						',/,&
			'\newcommand{\la}{\lambda}					',/,&
			'\newcommand{\eps}{\varepsilon}				',/,&
			'\newcommand{\xstar}{x^\star}				',/,&
			'\newcommand{\zstar}{z^\star}				',/,&
			'\newcommand{\xcirc}{x^\circ}				',/,&
			'\newcommand{\xtilde}{\tilde x}				',/,&
			'\newcommand{\xhat}{\hat x}					',/,&
			'\newcommand{\xbar}{\bar x}					',/,&
			'\newcommand{\lstar}{\la^\star}				',/,&
			'\newcommand{\lcirc}{\la^\circ}				',/,&
			'\newcommand{\ltilde}{\tilde\la}			',/,&
			'\newcommand{\lhat}{\hat\la}				',/,&
			'\newcommand{\lbar}{\bar\la}				',/,&
			'\newcommand{\leqd}{\leq_D}					',/,&
			'\newcommand{\trasp}{^\top}					',/,/,&
			'\renewcommand{\Re}{{\rm I}\! {\rm R}}		',/,&
			'\renewcommand{\arraystretch}{1.3}			',/,&
			'%\renewcommand{\baselinestretch}{1.1}		',/,/,&
			'\begin{document}							',/,/,&
			'\begin{center}\par							',/,&
			'{\bf (',I2,'/',I2,'/',I4,')}\par			',/,&
			'\begin{tabular}{l|c||c|c|c|c|c|c}			',/,&
			'PROBLEM & n & nF & nFott & F. min & F. medio & F. min & F. medio\\ \hline')

END PROGRAM
